package com.wc.alorithm_blue_bridge._数学知识.推导.Q2080;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * @Author congge
 * @Date 2023/10/11 22:26
 * @description 求和
 * https://www.lanqiao.cn/problems/2080/learning/?page=2&first_category_id=1&sort=students_count&second_category_id=3
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        // 总和，为了减少重复运算
        int sum = 0;
        // 当前输入数字
        int num;
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            num = sc.nextInt();
            sum += num;
            array[i] = num;
        }

        long ans = 0;
        // 当前项计算总和，减少重复运算
        long cur = 0;

        for (int i = 0; i < n - 1; i++) {
            sum -= array[i];
            cur = (long) array[i] * sum;
            ans += cur;
        }

        System.out.println(ans);
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
